<?php
/**
 * Created by PhpStorm.
 * User: minicart
 * Date: 2018/9/29
 * Time: 23:52
 */
namespace app\admin\service;
use app\models\EdubossModel;

/**
 * Class AdministrationService
 * @package app\admin\service
 */
class AdministrationService
{
    /**
     * 沟通记录管理
     * @return array
     */
    public function customer_follow_up_list()
    {
        try {
            $page = input('page',1);
            $listRows = input('limit',5);
            $name = input('name','');
            $student_grade = input('student_grade','');
            $channel = input('channel','');
            $type = input('type','');
            $school_class = input('school_class','');
            $where = [];
            if($name) $where['name'] = $name;
            if($channel) $where['channel'] = $channel;
            if($school_class) $where['school_class'] = $school_class;
            if($type) $where['type'] = $type;
            if($student_grade) $where['student_grade'] = $student_grade;
            $order = 'id desc';
            $customers = EdubossModel::pageLists($where, $page,$listRows, $order);
            return $customers;
        } catch (\Exception $ex) {
            return ['code' => 1, 'msg' => $ex->getMessage()];
        }
    }

    /**
     * 上门管理
     * @return array
     */
    public function appointment_manage()
    {
        try {
            $page = input('page',1);
            $listRows = input('limit',5);
            $name = input('name','');
            $student_grade = input('student_grade','');
            $channel = input('channel','');
            $type = input('type','');
            $school_class = input('school_class','');
            $where = [];
            if($name) $where['name'] = $name;
            if($channel) $where['channel'] = $channel;
            if($school_class) $where['school_class'] = $school_class;
            if($type) $where['type'] = $type;
            if($student_grade) $where['student_grade'] = $student_grade;
            $order = 'id desc';
            $customers = EdubossModel::pageLists($where, $page,$listRows, $order);
            return $customers;
        } catch (\Exception $ex) {
            return ['code' => 1, 'msg' => $ex->getMessage()];
        }
    }

    /**
     * 试听课管理
     * @return array
     */
    public function audition_order_list()
    {
        try {
            $page = input('page',1);
            $listRows = input('limit',5);
            $name = input('name','');
            $student_grade = input('student_grade','');
            $channel = input('channel','');
            $type = input('type','');
            $school_class = input('school_class','');
            $where = [];
            if($name) $where['name'] = $name;
            if($channel) $where['channel'] = $channel;
            if($school_class) $where['school_class'] = $school_class;
            if($type) $where['type'] = $type;
            if($student_grade) $where['student_grade'] = $student_grade;
            $order = 'id desc';
            $customers = EdubossModel::pageLists($where, $page,$listRows, $order);
            return $customers;
        } catch (\Exception $ex) {
            return ['code' => 1, 'msg' => $ex->getMessage()];
        }
    }

    /**
     * 转介绍管理
     * @return array
     */
    public function customer_new_introduce()
    {
        try {
            $page = input('page',1);
            $listRows = input('limit',5);
            $name = input('name','');
            $student_grade = input('student_grade','');
            $channel = input('channel','');
            $type = input('type','');
            $school_class = input('school_class','');
            $where = [];
            if($name) $where['name'] = $name;
            if($channel) $where['channel'] = $channel;
            if($school_class) $where['school_class'] = $school_class;
            if($type) $where['type'] = $type;
            if($student_grade) $where['student_grade'] = $student_grade;
            $order = 'id desc';
            $customers = EdubossModel::pageLists($where, $page,$listRows, $order);
            return $customers;
        } catch (\Exception $ex) {
            return ['code' => 1, 'msg' => $ex->getMessage()];
        }
    }
}